package com.ting.template.core.common.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/** 
* @ClassName: ProxyBeansFactory 
* @Description: 动态代理工厂实现类
* @author 雷霆
* @date 2016年7月5日
*  
*/
public class ProxyBeansFactory implements ApplicationContextAware {

	private static ApplicationContext applicationContext;
	
	private static ProxyBeansFactory self;
	
	public ProxyBeansFactory() {
		self  = this;
	}
	
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		ProxyBeansFactory.applicationContext = applicationContext;
	}
	
	
	public static ProxyBeansFactory getInstance() {
		return self;
	}
	
	public <T> T getBean(String name, Class<T> clazz) {
		return applicationContext.getBean(name, clazz);
	}
	
}
